package com.dsp.week12.rest;

import com.dsp.week12.model.MessageExt;
import com.dsp.week12.service.MyProducer;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class PulsarController {

    @Resource
    MyProducer myProducer;

    @RequestMapping(value = "/send1/{name}", method = RequestMethod.GET)
    public void sendMessage1(@PathVariable String name) {
        myProducer.sendTest(name);
    }

    @RequestMapping(value = "/send2/{name}", method = RequestMethod.GET)
    public void sendMessage2(@PathVariable String name) {
        myProducer.sendMsg(name);
    }

    @RequestMapping(value = "/send3/{name}", method = RequestMethod.GET)
    public void sendMessage3(@PathVariable String name) {
        myProducer.sendObj(new MessageExt(name));
    }

}
